//
//  Colors.swift
//  SwiftScienceChina
//
//  Created by 贾培军 on 2019/12/9.
//  Copyright © 2019 贾培军. All rights reserved.
//

import UIKit
public extension UIColor {
    convenience init(red: Int, green: Int, blue: Int, alpha: Float = 1.0) {
       assert(red >= 0 && red <= 255, "Invalid red component")
       assert(green >= 0 && green <= 255, "Invalid green component")
       assert(blue >= 0 && blue <= 255, "Invalid blue component")

       self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0)
    }
    
    convenience init(_ netHex:Int, alpha: Float = 1.0) {
        self.init(red:(netHex >> 16) & 0xff, green:(netHex >> 8) & 0xff, blue:netHex & 0xff, alpha:alpha)
    }
}


